Skip to content

[Type] Vec: Short-circuit toVecN for same-type conversions#6022

Merged
hugtalbot merged 3 commits into
sofa-framework:masterfrom
fredroy:vec_avoid_convert_same_type
Mar 24, 2026
Merged

[Type] Vec: Short-circuit toVecN for same-type conversions#6022
hugtalbot merged 3 commits into
sofa-framework:masterfrom
fredroy:vec_avoid_convert_same_type

Conversation

@fredroy

@fredroy fredroy commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Skip conversion logic when both Vec types are the same. The compiler likely optimizes this already, but the explicit check makes the intent clearer and avoids relying on the optimizer to see through std::copy/std::fill_n.

Measured with alxbilger/SofaBenchmark#46
No change with -O3 but it should make lesser optimization/debug run faster

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request labels Mar 17, 2026
@th-skam th-skam added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Mar 19, 2026
@hugtalbot hugtalbot merged commit 919ffbd into sofa-framework:master Mar 24, 2026
9 of 13 checks passed
@hugtalbot hugtalbot deleted the vec_avoid_convert_same_type branch March 24, 2026 15:57
@hugtalbot hugtalbot added this to the v26.06 milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: enhancement About a possible enhancement pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants